home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-26 | 3.2 KB | 112 lines | [TEXT/ZBAS] |
-
- DIM OldT1,OldL1,OldB1,OldR1
- DIM OldT2,OldL2,OldB2,OldR2
- DIM BigT,BigL,BigB,BigR
- DIM DestT,DestL,DestB,DestR
- DIM ViewT,ViewL,ViewB,ViewR
- DIM PT,PL,PB,PR
- DIM ZT,ZL,ZB,ZR
-
-
- LONG FN PrintDoc(TEHndl&)
- DEF PAGE
- DEF LPRINT
- LONG IF NOT PRCANCEL
- ' save original view and dest rects
- BLOCKMOVE PEEK LONG(TEHndl&),VARPTR(OldT1),16
- OldPort& = PEEK LONG(PEEK LONG(TEHndl&)+82) ' save old port of TE field
- EndLn = PEEK WORD(PEEK LONG(TEHndl&)+94) ' get total # of lines
- DocHt = FN TEGETHEIGHT(EndLn,1,TEHndl&)+10' get total doc height
- CALL TEDEACTIVATE(TEHndl&)
- BigT = 0 : BigL = 0 : BigB = 8192 : BigR = 8192' a wide open clip rect
- ZT = 0 : ZL = 0 : ZB = 0 : ZR = 0 ' a zero rect
-
- ROUTE 128
- PgSz = WINDOW(7)-2 ' get height of printer port
- TotalPg = DocHt/PgSz + 1 ' calc number of pages to print
- PgStartLn = 1 : PgEndLn = 1
- CALL GETPORT(PrPort&)
-
- ' get port rect
- BLOCKMOVE PrPort& + 16,VARPTR(PT),8
- POKE LONG PEEK LONG(TEHndl&)+82,PrPort& ' tell TE to output to printer
- BLOCKMOVE VARPTR(PT),VARPTR(DestT),8
- BLOCKMOVE VARPTR(PT),VARPTR(ViewT),8
- DestB = DestT + DocHt
-
- PrecHndl& = PRHANDLE
- FirstPg = PEEK WORD(PEEK LONG(PrecHndl&)+62)
- LastPg = PEEK WORD(PEEK LONG(PrecHndl&)+64)
- ' make doc size dest rect
- BLOCKMOVE VARPTR(DestT),PEEK LONG(TEHndl&),8
- ' make page size view rect
- BLOCKMOVE VARPTR(ViewT),PEEK LONG(TEHndl&)+8,8
-
- FOR Pg = 1 TO TotalPg
- CALL CLIPRECT(BigT) ' make wide open clipping rect
- DO
- PgEndLn=PgEndLn+1
- PgHt = FN TEGETHEIGHT(PgEndLn,PgStartLn,TEHndl&)
- UNTIL PgHt > PgSz OR PgEndLn > EndLn
- PgEndLn=PgEndLn-1 ' last one was too far
- PgHt = FN TEGETHEIGHT(PgEndLn,PgStartLn,TEHndl&)
- PB = PT + PgHt ' bottom of update = last whole line
- LONG IF Pg => FirstPg AND Pg <= LastPg
- CALL TEUPDATE(PT,TEHndl&)
- IF Pg<TotalPg THEN CLEAR LPRINT
- END IF
- CALL CLIPRECT(ZT) ' zero rect for clipping
- IF TotalPg > 1 THEN CALL TESCROLL(0,-PgHt,TEHndl&)' scroll pg into view
- PgStartLn = PgEndLn + 1 : PgEndLn = PgStartLn
- NEXT
-
- ROUTE 0
- CLOSE LPRINT
- ' restore view & dest rects
- BLOCKMOVE VARPTR(OldT1),PEEK LONG(TEHndl&),16
- POKE LONG PEEK LONG(TEHndl&)+82,OldPort& ' restore original port, too
- CALL TEACTIVATE(TEHndl&)
- END IF
- END FN
-
-
- COORDINATE WINDOW:WIDTH-2
-
- MENU 1,0,1,"File"
- MENU 1,1,1,"Print"
- MENU 1,2,1,"Quit"
-
- ON MENU GOSUB "Menu"
- ON BREAK GOSUB "Break"
- ON DIALOG GOSUB "Dialog"
-
- WINDOW #1,"Edit Field Print Test",(40,40)-(490,310),1
- EDIT FIELD 1,"This is an edit field.",(4,4)-(432,250),2
- CALL TEAUTOVIEW(-1,TEHANDLE(1))
-
- "Loop"
- MENU ON:BREAK ON : DIALOG ON
- MENU OFF:BREAK OFF : DIALOG OFF
- GOTO "Loop"
-
- "Menu"
- MenuID = MENU(0):ItemID = MENU(1)
-
- ON ItemID GOTO "Print","Quit"
-
- "Dialog"
- Act = DIALOG(0):Ref = DIALOG(Act)
- RETURN
-
-
- "Print"
- TEHndl& = TEHANDLE(1)
- FN PrintDoc(TEHndl&)
- MENU
- RETURN
-
- "Quit"
- "Break"
- END
-
-